/*
 * Created by JFormDesigner on Tue Oct 21 20:46:15 CST 2025
 */

package com.yeban.bams.client;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * @author yeban
 */
public class MainPanel extends JPanel {

    private ATMClient atm;

    public MainPanel(ATMClient atm) {
        this.atm = atm;
        initComponents();
        // 绑定登录按钮事件
        //loginButton.addActionListener(e -> login(e));
    }

    // 【注册】 跳转至注册页面
    private void register(ActionEvent e) {
        CardLayout cardLayout = (CardLayout) this.getParent().getLayout();
        cardLayout.show(this.getParent(), "registerPanel");
    }

    // 【登录】 跳转至登录页面
    private void login(ActionEvent e) {
        CardLayout cardLayout = (CardLayout) this.getParent().getLayout();
        cardLayout.show(this.getParent(), "loginPanel");
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        mainTitle = new JLabel();
        registerButton = new JButton();
        loginButton = new JButton();

        //======== this ========
        setLayout(null);

        //---- mainTitle ----
        mainTitle.setText("\u6a21\u62df  ICBC  BAMS  \u7ec8\u7aef");
        mainTitle.setHorizontalAlignment(SwingConstants.CENTER);
        mainTitle.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 30));
        mainTitle.setForeground(Color.green);
        add(mainTitle);
        mainTitle.setBounds(65, 90, 370, 185);

        //---- registerButton ----
        registerButton.setText("\u6ce8\u518c");
        registerButton.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 18));
        registerButton.addActionListener(e -> register(e));
        add(registerButton);
        registerButton.setBounds(100, 310, 120, 70);

        //---- loginButton ----
        loginButton.setText("\u767b\u5f55");
        loginButton.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 18));
        loginButton.addActionListener(e -> login(e));
        add(loginButton);
        loginButton.setBounds(275, 310, 120, 70);

        setPreferredSize(new Dimension(500, 650));
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    private JLabel mainTitle;
    private JButton registerButton;
    private JButton loginButton;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
